#include <REGX52.H>

unsigned char  code SMG[18] =	{0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x88,0x80,0xc6,0xc0,0x86,0x8e,0xbf,0x7f};//0~9,A~F,还有小数点和一横
	
	void Delay (unsigned int t)
	{
		while(t--);
		while(t--);

	}
	
void InitHC138(unsigned char n)
{
	switch(n)
	{
		case 4:
			P2 = (P2 & 0x1f) | 0x80;
			break;
		case 5:
			P2 = (P2 & 0x1f) | 0xa0;
			break;
		case 6:
			P2 = (P2 & 0x1f) | 0xc0;
			break;
		case 7:
			P2 = (P2 & 0x1f) | 0xe0;	
			break;
	
	}
}

void ShowSMG(unsigned char dat,unsigned pos)
{
	InitHC138(6);
	P0 = 0x01<<pos;
	InitHC138(7);
	P0 = dat;
}

void SMG_static()
{
	unsigned char i,j = 0;
	for( i = 0;i < 8;i++)
	{
		for( j = 0;j < 10;j++)
		{
		ShowSMG(SMG[j],i);
		Delay(50000);
		}
	}
	for( j = 0;i < 16;i++)
	{
			InitHC138(6);
		P0 = 0xff;
		InitHC138(7);
		P0 = SMG[j];
				Delay(50000);
	}
}
void main()
{

	while(1)
	{
		SMG_static();
	}
}
